package com.ylr.retrofitLearning.Interceptor;

import com.github.lianjiatech.retrofit.spring.boot.interceptor.BasePathMatchInterceptor;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

/**
 * @ClassName SignInterceptor
 * @Description TODO 扩展自定义注解的实现类
 * @Author ylr
 * @Date 2021/7/23 16:10
 * @Version 1.0
 */
public class SignInterceptor extends BasePathMatchInterceptor {
    private String accessKeyID;
    private String accessKeySecret;

    public void setAccessKeyID(String accessKeyID) {
        this.accessKeyID = accessKeyID;
    }

    public void setAccessKeySecret(String accessKeySecret) {
        this.accessKeySecret = accessKeySecret;
    }

    @Override
    protected Response doIntercept(Chain chain) throws IOException {
        Request request = chain.request();
        Request newReq = request.newBuilder()
                .addHeader("accessKeyID", accessKeyID)
                .addHeader("accessKeySecret", accessKeySecret)
                .build();
        System.out.println(newReq.toString());
        return chain.proceed(request);


    }
}
